#region Summary

// 
// Owner : JackieHan 
// 
// Solution : Skomart.Spider
// 
// Project :Jackie.Utility.Test
// 
// File : TestCollectionExtension.cs
// 
// CopyRight : Copyright © 2010-2011 Skomart Corporation, All Rights Reserved 
// 
// Summary : 测试扩展集合方法
// 
// History : 
//			2010-12-09 10:47:52    Create 
// 

#endregion

#region Using

using System.Collections.Generic;
using System.Linq;
using NUnit.Framework;
using Jackie.Utility.CustomExtension;

#endregion

namespace Jackie.Utility.Test
{
    /// <summary> 
    /// 测试扩展集合方法
    /// </summary>
    [TestFixture]
    public class TestCollectionExtension
    {
        private class TestClass
        {
            public string Code { get; set; }
        }

        private IList<TestClass> testClasses;

        [SetUp]
        public void SetUp()
        {
            testClasses = new List<TestClass>
                              {
                                  new TestClass {Code = "AAA"},
                                  new TestClass {Code = "BB"},
                                  new TestClass {Code = "AAA"},
                                  new TestClass {Code = "BB"},
                                  new TestClass {Code = "AAA"},
                                  new TestClass {Code = "BB"},
                                  new TestClass {Code = "AAA"},
                              };
        }

        [Test]
        public void TestDistinct()
        {
            var distinctCollections = testClasses.Distinct(o => o.Code).ToList();
            Assert.AreEqual(2, distinctCollections.Count);
        }

        [TearDown]
        public void TearDown()
        {
        }
    }
}